#include <iostream>
#include <vector>
using namespace std;

vector<int> mul(const vector<int> &a, int b) {
    vector<int> ans;
    int n = a.size();
    int k = 0;
    for(int i = 0; i < n; i++) {
        int s = a[i] * b + k;
        ans.push_back(s % 10);
        k = s / 10;
    }
    while(k) {
        ans.push_back(k % 10);
        k /= 10;
    }
    return ans;
}

vector<int> add(const vector<int> &a, const vector<int> &b) {
    vector<int> ans;
    int k = 0;
    int x = a.size(), y = b.size();
    int n = max(x,y);
    for(int i = 0; i < n; i++) {
        int s = a[i] + b[i] + k;
        ans.push_back(s % 10);
        k = s / 10;
    }
    if(k) {
        ans.push_back(k);
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<int> sum = {0};
    vector<int> fact = {1};  // 1!

    for (int i = 1; i <= n; i++) {
        fact = mul(fact, i);
        sum = add(sum, fact);
    }

    // 输出结果（倒序输出）
    for (int i = sum.size() - 1; i >= 0; i--) {
        cout << sum[i];
    }
    cout << endl;
    return 0;
}
